<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function isCircleObject(obj) {
        const cache = new Set();
        let isFind = false;
        const find = function (obj) {
            for(let key in obj) {
                const value = obj[key];
                if (cache.has(value)) {
                    isFind = true;
                    return;
                } else {
                    cache.add(value)
                }
                find(value);
            }
        }
        find(obj);
        return isFind;
    }

    var obj = {
        obj1: {
            obj2: {
                obj3: {
                    obj4: 'hello'
                }
            },
            obj21: {
               obj31: 'world'
            }
        }
    }
    obj.obj1.obj21 = obj;
    console.log(isCircleObject(obj));
</script>
</body>
</html>